class ToggleBlock {
    init() {
        // 绑定折叠/展开按钮
        const toggleBtn = document.getElementById('toggleDefinition');
        if (toggleBtn) {
            toggleBtn.addEventListener('click', this.toggleDefinitionBlock);
        }
        const toggleBtn2 = document.getElementById('toggleDefinition-fields-container');
        if (toggleBtn2) {
            toggleBtn2.addEventListener('click', this.toggleDefinitionBlock2);
        }
        //toggleDefinition-button-container,
        //toggleDefinition-onload-container
        //toggleDefinition-onsave-container
        const toggleBtn3 = document.getElementById('toggleDefinition-onsave-container');
        if (toggleBtn3) {
            toggleBtn3.addEventListener('click', this.toggleDefinitionBlock2);
        }
        const toggleBtn4 = document.getElementById('toggleDefinition-onload-container');
        if (toggleBtn4) {
            toggleBtn4.addEventListener('click', this.toggleDefinitionBlock2);
        }
        const toggleBtn5 = document.getElementById('toggleDefinition-button-container');
        if (toggleBtn5) {
            toggleBtn5.addEventListener('click', this.toggleDefinitionBlock2);
        }
    }
    // 折叠/展开定义块
    toggleDefinitionBlock() {
        const definitionHeader = document.querySelector('.definition-header');
        const toggleBtn = document.getElementById('toggleDefinition');

        if (definitionHeader.classList.contains('collapsed')) {
            definitionHeader.classList.remove('collapsed');
            toggleBtn.classList.remove('collapsed');
            toggleBtn.textContent = '●';
        } else {
            definitionHeader.classList.add('collapsed');
            toggleBtn.classList.add('collapsed');
            toggleBtn.textContent = '○';
        }
    }
    toggleDefinitionBlock2(sender) {
        
        const toggleBtn = sender.srcElement;
        const definitionHeader = toggleBtn.parentElement.parentElement;

        if (definitionHeader.classList.contains('collapsed')) {
            definitionHeader.classList.remove('collapsed');
            toggleBtn.classList.remove('collapsed');
            toggleBtn.textContent = '●';
        } else {
            definitionHeader.classList.add('collapsed');
            toggleBtn.classList.add('collapsed');
            toggleBtn.textContent = '○';
        }
    }
}
export default new ToggleBlock();